package com.jinghao.ctws.service.impl;

import java.util.List;
import java.util.Map;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.springframework.stereotype.Service;

import com.jinghao.core.common.exception.JingHaoCustomerException;
import com.jinghao.core.common.service.impl.JingHaoBaseServiceImpl;
import com.jinghao.core.common.util.cnd.JhCnd;
import com.jinghao.ctws.service.ICwvVideoPlayConfigService;
import com.jinghao.ctws.entity.CwvVideoPlayConfig;

@Service("cwvVideoPlayConfigService")
public class CwvVideoPlayConfigServiceImpl extends JingHaoBaseServiceImpl<CwvVideoPlayConfig> implements ICwvVideoPlayConfigService {


	//==================定制内容开始======================
//在这里修改代码
	@Override
	public void listCwvVideoPlayConfig(CwvVideoPlayConfig model) {
		model.setMapList(this.queryMapList(model));
		
	}

	@Override
	public void addCwvVideoPlayConfig(CwvVideoPlayConfig model) {
		List<Map<String,Object>> list=this.queryMapList(model);
		if (StringUtils.isEmpty(model.getIp())) {
			throw new JingHaoCustomerException("IP地址不能为空！");
		}
		if (StringUtils.isEmpty(model.getPort())) {
			throw new JingHaoCustomerException("端口不能为空！");
		}
		if (!StringUtils.isEmpty(model.getVpUuid())) {
			//删除历史数据
			if(list!=null&&list.size()>0){
				JhCnd cnd=new JhCnd();
				cnd.andEquals("vpUuid");  
				model.setJhCnd(cnd);
				this.deleteSame(model);
			}
		}
		//保存数据
		model.setVpUuid(model.getUUID());
		this.add(model);
		
	}
	
	//==================定制内容结束======================
}
